/* 
Scenic Graphics Library
Copyright (C) 2007 Jouni Tulkki

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USApackage scenic;
*/

package scenic.path;

import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;

/**
 * This class defines a straight line segment. This class does not 
 * define the start point of the line. The start point is the 
 * end point of the previous segment.
 */
public class LineSegment implements Segment {
	private double x;
	private double y;
	
	/**
	 * Creates a straight line segment with the given parameters.
	 * 
	 * @param x the x coordinate of the end point.
	 * @param y the y coordinate of the end point.
	 */
	public LineSegment(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Gets the x coordinate of the end point.
	 */
	public double getX() {
		return x;
	}

	/**
	 * Gets the y coordinate of the end point.
	 */
	public double getY() {
		return y;
	}

	public void walk(PathWalker walker, Point2D.Double position, AffineTransform error) {
		walker.lineTo(x, y);
		position.x = x;
		position.y = y;
	}
	
	public void getBounds(AffineTransform transform, Rectangle r, Point2D.Double position) {
		Path.addPointToBounds(transform, r, x, y);
		
		position.x = x;
		position.y = y;
	}
	
}
